package com.best.oasis.settlement.web.action.security;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.stereotype.Service;

import com.best.oasis.settlement.common.entity.security.RoleGroup;
import com.best.oasis.settlement.common.so.security.RoleGroupSO;
import com.best.oasis.settlement.common.vo.security.RoleGroupVO;
import com.best.oasis.settlement.service.security.RoleGroupService;
import com.best.oasis.settlement.util.convert.ConvertUtil;
import com.best.oasis.settlement.util.page.PageList;
import com.best.oasis.settlement.web.action.base.BaseActionImpl;

@RemotingDestination
@Service
public class RoleGroupActionImpl extends BaseActionImpl<RoleGroupVO, RoleGroup> implements RoleGroupAction {

	@Autowired
	private RoleGroupService rolegroupService;
	
	@Override
	public void afterConstruct() {
		super.setBaseService(rolegroupService);
	}

    public String removeRoleGroups(List<Long> ids) {
    	List<Long> result=ConvertUtil.toLongs(ids);
    	try{    		
    		for(int i=0;i<result.size();i++){
    			rolegroupService.remove(result.get(i));
    		}
    		return SUCCESS;
    	}
    	catch(RuntimeException e){
    		return e.getMessage();
    	}

    }
    public PageList<RoleGroupVO> getRoleGroupPageList(RoleGroupSO so) {
    	if(so == null){
    		so = new RoleGroupSO();
    	}
        return rolegroupService.getRoleGroupPageList(so);
    }
    public RoleGroupVO update(RoleGroupVO vo) {
    	
    	return rolegroupService.update(vo);
        
    }
    public Boolean roleNameExist(String roleName){
    	RoleGroupVO vo = rolegroupService.getByRoleName(roleName);
    	if(vo != null){
    		return true;
    	}else{
    		return false;
    	}
    	
    }
}
